<include file="public@header" />
<div class="wrapper">
	<section class="content">
		<div class="container-fluid">


			<table class="table table-hover table-bordered" id="goos_table">
				<thead>
				<tr>
					<th>
						<input type="hidden" id="selected_ids" value="{$selected_ids}">
						<input type="hidden" id="selected_names" value="{$selected_names}">
						请选择
					</th>
					<th width="30%">姓名</th>
					<th width="30%">员工账号</th>
					<th width="30%">部门</th>
				</tr>
				</thead>
				<tbody>

				<foreach name="usersList" item="vo">
					<tr>
						<td class="text-left">
							<input type="checkbox" name="user" value="{$vo.id},{$vo.user_nickname}" <if condition="in_array($vo.id,$notice_ids)"> checked</if>/>
						</td>
						<td>{$vo['user_nickname']}</td>
						<td>{$vo['user_login']}</td>
						<td>{$vo['department_name']}</td>
					</tr>
				</foreach>
				<tr>
					<td class="text-right" colspan="5">
						<a href="javascript:void(0)" id="select_notice"  class="btn btn-info">确定选择</a>
					</td>
				</tbody>
			</table>

			<div class="pagination">{$page}</div>
			</form>

		</div>
	</section>
</div>

<script type="text/javascript" src="__STATIC__/js/admin.js?v={:time()}"></script>
<script type="text/javascript" src="__STATIC__/js/layer/layer.js"></script>
<script type="text/javascript">

	/*元素全选*/
	// document.getElementById("check").onclick = function(){
	// 	var checked = document.getElementById("check").checked;
	// 	var checkson = document.getElementsByName("user");
	// 	if (checked){
	// 		for(var i = 0; i < checkson.length ;i++){
	// 			checkson[i].checked = true;
	// 		}
	// 	} else{
	// 		for (var i = 0; i < checkson.length; i++){
	// 			checkson[i].checked = false;
	// 		}
	// 	}
	// };
    $("input[name='user']").click(function(){
        if($(this).is(':checked')){
            var str = $(this).val().split(",");
            $("#selected_ids").val($("#selected_ids").val()+str[0]+",");
            $("#selected_names").val($("#selected_names").val()+str[1]+",");
		}else{
            var str = $(this).val().split(",");
            $("#selected_ids").val($("#selected_ids").val().replace(str[0]+",", ''));
            $("#selected_names").val($("#selected_names").val().replace(str[1]+",", ''));
        }
    })
	/*人员勾选添加*/
	$("#select_notice").click(function(){
		if($("input[type='checkbox']:checked").length == 0)
		{
			alert('请选择通知人员');
			return false;
		}

        var notice_ids = $("#selected_ids").val();
        var notice_name = $("#selected_names").val();
		// $("input[type='checkbox']").each(function(){
		// 	if($(this).is(':checked') == true && $(this).val() != 'on')
		// 	{
		// 		var str = $(this).val().split(",");
        //
		// 		notice_ids += str[0]+",";
		// 		notice_name += str[1]+ "<br/>";
        //
		// 	}
		// });
		if(notice_ids.indexOf(",") != -1){
			notice_ids = notice_ids.substr(0,notice_ids.length -1);
			notice_name = notice_name.substr(0,notice_name.length -1);
		}
		window.parent.document.getElementById("userIdSelect").value=notice_ids;
		window.parent.document.getElementById("usersNameSelect").innerHTML=notice_name;

		var index = parent.layer.getFrameIndex(window.name);
		parent.layer.close(index);

	});
    $(".page-link").click(function(){
        var notice_ids = $("#selected_ids").val();
        var notice_names = $("#selected_names").val();
		var url = $(this).attr("href");
		$(this).attr("href",url+"&notice_ids="+notice_ids+"&notice_names="+notice_names);
    })
</script>

</body>
</html>





